package account;

public class Account {
    private double balance;

    public Account(double initialBalance) {
        if(initialBalance<0){
            throw new IllegalArgumentException("初始余额不能为负数");
        }
        this.balance = initialBalance;
    }

    public void deposit(double amount) {
        if (amount < 0) {
            throw new IllegalArgumentException("存款金额不能为负数");
        }
        balance += amount;
    }

    public void withdraw(double amount)throws InsufficientFundsException{
        if (amount < 0) {
            throw new IllegalArgumentException("取款金额不能为负数");
        }
        if (amount > balance) {
            throw new InsufficientFundsException("账户余额不足!");
        }
        balance -= amount;
    }

    public double getBalance() {
        return balance;
    }
}
